package exec;

import java.util.Arrays;

public class Exec04 {

    public static void main(String[] args) {
        // System 类中的 arraycopy 方法实现 删除元素
        int[] nums = {2, 11, 33, 44, 55, 66, 277};
        int[] newNums = new int[nums.length - 1];
        int key = 33;
        int index = -1;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == key) {
                index = i;
            }
        }
        if (index < 0) {
            System.out.println("数字不存在");
        } else {
            System.arraycopy(nums, 0, newNums, 0, index);
            System.arraycopy(nums, index + 1, newNums, index, newNums.length - index);
            System.out.println(Arrays.toString(newNums));
        }
    }
}
